﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using OpenTK.Graphics.OpenGL;

namespace GLPong
{
    class Palette : IPhysicalDrawable
    {
        float _x, _y;
        float _w, _h;
        float _s; //palette's speed
        Color _paletteColor;

        public float X { get { return _x; } }
        public float Y { get { return _y; } }
        public float W { get { return _w; } }
        public float H { get { return _h; } }

        public Palette(float x, float y, float w, float h, Color _color)
        {
            _paletteColor = _color;
            _x = x;
            _y = y;
            _w = w;
            _h = h;
            _s = 0;
        }

        void IDrawable.Display()
        {
            GL.Begin(BeginMode.Quads);
            GL.Color3(_paletteColor);
            GL.Vertex3(_x + _w / 2, _y + _h / 2, 0);
            GL.Vertex3(_x + _w / 2, _y - _h / 2, 0);
            GL.Vertex3(_x - _w / 2, _y - _h / 2, 0);
            GL.Vertex3(_x - _w / 2, _y + _h / 2, 0);
            GL.End();
        }

        public void UpdatePosTmp(float delta)
        {
            _y += delta;
        }
        
        public void UpdatePos(long delta)
        {
            //To be implemented
        }

        public void UpdateSpeed(int val)
        {
            _s += val;
        }

        public void Slow()
        {
            _s /= 0.1f;
        }
    }
}
